/*******************************************************************/
/* @ All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.        */
/*                                                                 */
/*  NAME      = __l7_node_free.c                                   */
/*  NOTE      =                                                    */
/*  DATE      = 2016/04/18 by jikw                                 */
/*******************************************************************/

#include <CUnit/Basic.h>
#include <stdlib.h>

#include "frcomm.h"
#include "frmem.h"
#include "conntrack.h"
#include "frct_comm.h"
#include "frexp_comm.h"
#include "t_frstat_ct_conn.h"

#define L7_CONNS_HASH_SIZE   100

typedef struct __l7_conns {
    int     i_l7_proto;

    unsigned long ul_conns;
    unsigned long ul_conns_avg[4];
} L7_conns;

typedef struct __ct_conns {
    unsigned long ul_conns;             //连接数
    unsigned long ul_conns_avg[4];      //历次连接数

    Frhash_header st_l7_conns;          //模块信息hash
} Frct_conns;

extern void __l7_node_free(Frlist_node* p_node);

static int __suite_init(void)
{

	return 0;
}

static int __suite_cleanup(void)
{

	return 0;
}

static void case1(void)
{
    __l7_node_free(NULL);
    return;
}

static void case2(void)
{
    Frlist_node st_node;
    memset(&st_node, 0x0, sizeof(Frlist_node));
    __l7_node_free(&st_node);
    return;
}

static void case3(void)
{
    L7_conns *p_st_data = NULL;
    Frlist_node *p_st_node;

    p_st_data = (L7_conns *)frmalloc(sizeof(L7_conns));
    memset(p_st_data, 0x0, sizeof(L7_conns));
    p_st_node = frlist_node_create(p_st_data);

    __l7_node_free(p_st_node);

    frfree(p_st_node);
    return;
}

int add_suite__l7_node_free(void)
{
    CU_pSuite pSuite = NULL;

    if ((pSuite = CU_add_suite("framework __l7_node_free()", __suite_init, __suite_cleanup)) == NULL)
        return FR_FAIL;

    if (CU_add_test(pSuite, "case1", case1) == NULL ||
        CU_add_test(pSuite, "case2", case2) == NULL ||
        CU_add_test(pSuite, "case3", case3) == NULL)
        return FR_FAIL;

    return FR_SUCC;
}
